<?php
// Returns whether or not the post was added successfully
// $time should be an integer, unix time
// $author get from $_SESSION['idusers'] in all 3
function addNewPost($title, $author, $content, $event_idevents)
{
	$time = date("Y-m-d H:i:s");
	return mysql_query("INSERT INTO `posts` VALUES ('$title','$author','$content','$time','$event_idevents')");
}

// Returns the number of rows updated
function updatePost($title, $author, $content, $event_idevents)
{
	$content = $content . '<BR /><BR />Last updated on: ' . date("Y-m-d H:i:s");
	return mysql_query("UPDATE `posts`
		SET `content`='$content', `time`='$time', `event_idevents`='$event_idevents'
		WHERE `title`='$title' AND `author`='$author'");
}

// Returns the number of deleted rows
function removePost($title, $author)
{
	return mysql_query("DELETE FROM `posts` WHERE `title`='$title' AND `author`='$author'");
}
?>